#ifndef PLAYER_H
#define PLAYER_H

#include "character.h"
#include "event.h"
#include "user.h"
#include <list>

#define MaxPlayer 7

class CPlayer
{
public:
	string Name;

	bool Available;
	T_ModuleDescriptor User;

	typedef unsigned int T_PlayerIndex;

public:
	CCharacter *CharSelf;
	CCharacter *CharHate;
	CCharacter *CharLove;

	CCharacter::T_Status CurrentStatus;
	bool Fought;
	bool Boated;
	int CurrentLife;
	int CurrentPosition;	
	CCardSet Equipment;
	CCardSet Inventory;

	bool WaitInput;
	CEvent::T_MustInputAction WaitingAction;
	T_PlayerIndex Index;


public:
	CPlayer() : Available(1) , WaitInput(0) {}
	void Init();
	void Input(CEvent e);
	void Output(CEvent e);
	void GetInput(CEvent e);
};


class CPlayerManage
{
public:
	CPlayer Player[MaxPlayer];
	int AlivePlayer;
	int PlayerNumber;
	list<int> LastPosition;
	list<int> CurrentPosition;

public:
	int AllocateFreePlayer(T_ModuleDescriptor user)
	{
		for (int i = 0; i < MaxPlayer; i++ )
		{
			if(Player[i].Available == 1)
			{
				Player[i].Available = 0;
				Player[i].User = user;
				PlayerNumber++;
				return i;
			}
		}
		return -1;
	}

	int GetAliveChar()
	{
		int c = 0;
		for (int i = 0; i < PlayerNumber; i++ )
		{
			if (Player[i].CurrentStatus == CCharacter::Healthy)
			{
				c++;
			}
		}
		return c;
	}	

	CPlayerManage() : PlayerNumber(0) {}
};



#endif
